<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="msapplication-window" content="width=device-width;height=device-height">
<title>去钓鱼</title>
<link rel="stylesheet" href="../css/common/jquery.mobile-1.4.5.min.css">
<link type="text/css" rel="stylesheet" charset="utf-8" href="../plugins/bootstrap/css/bootstrap.min.css">

<link rel="stylesheet" href="../css/common/weui.min.css">
<link rel="stylesheet" href="../css/common/jquery-weui.min.css">
<link rel="stylesheet" href="../css/common/unslider.css">
<link rel="stylesheet" href="../css/home.css">

<script src="../js/common/jquery-2.0.0.js"></script>
<script src="../js/common/jquery.mobile-1.4.5.js"></script>
<script src="../js/common/velocity.min.js"></script>
<script src="../js/common/jquery.event.move.js"></script>
<script src="../js/common/jquery.event.swipe.js"></script>
<script src="../js/common/unslider-min.js"></script>
<script src="../js/common/jquery.yestop.js"></script>

<script src="../js/common/yxMobileSlider.js"></script>
<!--
	作者：wyy8@live.cn
	时间：2017-06-06
	描述：微信
-->
<script type="application/javascript" src="../js/common/jweixin-1.0.0.js"></script>
<script type="application/javascript" src="../js/common/jquery-weui.min.js"></script>

<script src="../js/ajax_req.js"></script>
<script src="../js/api.js"></script>
<script src="tmpl/home.js"></script>

<!--模板-->
<script type="application/javascript" src="../plugins/jquery-tmpl/jquery.tmpl.js"></script>
<script type="application/javascript" src="../plugins/jquery-tmpl/jquery-jtemplates.js"></script>

</head>
<body style="overflow: hidden;">
	<div data-role="page" id="toppage">
		<div id="sds">
			<div class="slider">
			  <ul id="ul-slider">
			  </ul>
			</div>
		</div>
		
		<div id="home_top"></div>
		
		<div id="box">
			
		</div>
	</div>
	
	<div data-role="footer" data-position="fixed" class="foot-div">
			
	        <div class="gouwuche_content" onclick="goHome()">
	        	<span class="gouwuche_icon" style="margin-left: -2px;"><img src="../image/jx_s.png" width="20px"></span>
	        	<a href="#" data-icon="shop" style="color: #347B00;text-decoration: none;">精选</a>
	        </div>
	        
	        <div class="gouwuche_content" onclick="goSeckill()">
	        	<span class="gouwuche_icon" style="margin-left: -2px;"><img src="../image/ms_us.png" width="20px"></span>
	        	<a href="#" data-icon="shop" style="text-decoration: none;color: #333;">秒杀</a>
	        </div>
	        
	        <div class="gouwuche_content" onclick="myShopping()">
	        	<span class="gouwuche_icon" style="margin-left: 1rem;">
	        		<img src="../image/wd_us.png" width="20px">
	        		<span class="badge"></span>
	        	</span>
	        	<a href="#" data-icon="star" style="text-decoration: none;color: #333;">我的鱼篓</a>
	        	
	        </div>
	        
	        <div class="gouwuche_content" onclick="memberClick()">
	        	<span class="gouwuche_icon" style="margin-left: 1rem;"><img src="../image/hy_us.png" width="20px"></span>
	        	<a href="#" style="text-decoration: none;color: #333;">会员中心</a>
	        </div>
	        
	    </div>
</body>

<script>
	var setHeight = function(e){
		console.log($(e).height())
		//$("#hot_goods .banner").height($(e).height()); 
	}
	
	ajax(api.toHomeData,{},function(data){
		console.log("home data 1 : ",data)
		
		// 轮播图
		//banner
		if(data.banners != null){
			for(var i=0;i<data.banners.length;i++){
				$(".slider ul").append("<li onclick='themeClick(0,\""+data.banners[i].url+"\")'><img style=\"width:"+window.screen.width+"px;height:"+window.screen.width*175/375+"px\" onload=\"img_onload(this)\" src=\""+data.banners[i].img_url+"\"></li>")
			}
			$(".slider").yxMobileSlider({width:window.screen.width,during:3000,height:window.screen.width*175/375})
		}
		
		//商品详情
		if( data.products != null ){
			for( var index = 0 ; index < data.products.length; index++ ){
				if(data.products[index].product_image_lst_store != null){
					data.products[index].product_image_lst_store += ","
					data.products[index].image = data.products[index].product_image_lst_store.split(',')[0]
				}
			}
			$("#home_top").setTemplateURL('tmpl/home_top.html');
			$("#home_top").setParam("width", window.screen.width); 
			$("#home_top").processTemplate(data.products);
		}
		
		//购物车状态
		gouwuche_changed()
		//评论下拉刷新控件
	    $('#box').load("comm/loadmore.html", function(data){
			loaded(0, {url:api.toHomeData, page:'tmpl/homeTmpl.html', para:{}})
		});
	})
	
	//图片加载
    function img_onload(obj){
		obj.width=window.screen.width
	}
    
    function myShopping(){
    	window.location.href="myShoppingCart.html"
    }
    
    function goHome(){
		window.location.href="home.html"
	}
    
    function goSeckill(){
		window.location.href="seckills.html"
	}
    
    function memberClick(){
    	window.location.href="http://cs.tzfwzx.cn/fishing/site/user/index"
    }
    
    //详情点击
    function locationClick(id){
    	window.location.href="goods.html?id="+id;
    }
    
    //主题点击
    function themeClick(id, url){
    	console.log("id"+id+"url"+url)
    	if(url == null){
    		window.location.href="theme.html?id="+id
    	}else{
    		window.location.href=url
    	}
    	
    }
    
    //购物车图标更改
    function gouwuche_changed(){
		ajax(api.getCartItemNum, {}, function(data){
			if(data != null && data.num != null && data.num != 0){
				if(data.num>99){
					//$(".badge").text("99+")
				}else if(data.num>9){
					//$(".badge").text(data.num)
				}else{
					//$(".badge").text(data.num)
				}
				$(".badge").css("display","block")
			}else{
				$(".badge").css("display","none")
			}
		})
    }
    
    //gotop
	function gotop(){
		$('#toppage').animate({scrollTop:0},500);
		 return false;
	}
</script>
</html>